package cn.wanho.service.impl;

import cn.wanho.dao.CmsStageMapper;
import cn.wanho.dto.CmsStage;
import cn.wanho.rvo.ResultEnum;
import cn.wanho.rvo.ResultVO;
import cn.wanho.rvo.StageVO;
import cn.wanho.service.CmsStageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CmsStageServiceImpl implements CmsStageService {
    @Resource
    private CmsStageMapper cmsStageMapper;
    /**
     * 创建阶段
     * @param stageName
     * @return
     */
    @Override
    public ResultVO addStage(String stageName) {
        System.out.println(stageName);
        int i = cmsStageMapper.insertStage(stageName);
        System.out.println(i);
        if (i>0) {
            return ResultVO.success(ResultEnum.STAGE_CREATE_SUCCESS.getResCode(), ResultEnum.STAGE_CREATE_SUCCESS.getResMsg());
        }else{
            return ResultVO.failure(ResultEnum.STAGE_CREATE_FAILURE.getResCode(), ResultEnum.STAGE_CREATE_FAILURE.getResMsg());
        }
    }

    /**
     * 获取阶段列表
     * @return
     */
    @Override
    public ResultVO getStageList() {
        List<StageVO> stageList = cmsStageMapper.getStageList();
        return ResultVO.success(ResultEnum.GET_STAGE_SUCCESS.getResCode(), ResultEnum.GET_STAGE_SUCCESS.getResMsg(),stageList);
    }
}
